<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title>登录</title>

    <link rel="stylesheet" href="static/css/login.css">
    <link rel="stylesheet" type="text/css" href="static/css/sweetalert.css">
    <style type="text/css">
        body {
            color: #333;
            font-size: 13px;
        }

        input, select, textarea {
            color: #333;
        }

        .bg {
            width: 100%;
            height: 100%;
            position: absolute;
            background-image: linear-gradient(to top, #fbc2eb 0%, #a6c1ee 100%);
        }

        .panel {
            background: #fff;
        }

        form .form-group:last-child {
            padding-bottom: 0;
        }

        .passcode {
            position: absolute;
            right: 0;
            bottom: 0;
            height: 32px;
            margin: 1px;
            border-left: solid 1px #ddd;
            text-align: center;
            line-height: 32px;
            border-radius: 0 4px 4px 0;
        }

        ul, li {
            list-style-type: none;
        }

        .field-icon-right .icon {
            bottom: 0px;
            top: auto
        }

        .loginbox {
            background: url(static/images/tmbg-white.png);
            border: 0px;
        }

    </style>
</head>

<body onkeydown="keyLogin()">

<div class="bg"></div>
<div class="container">
    <div class="line bouncein">
        <div class="xs6 xm4 xs3-move xm4-move">
            <div style="height:150px;"></div>
            <div class="media media-y margin-big-bottom">
            </div>
            <form action="static/html/index.html" method="post">
                <div class="panel loginbox">
                    <div class="text-center margin-big padding-big-top">
                        <h1>58新媒体后台管理系统</h1>
                    </div>
                    <div class="panel-body" style="padding:30px; padding-bottom:10px; padding-top:10px;">
                        <div class="form-group">
                            <div class="field field-icon-right">
                                <input type="text" class="input input-big" name="accounts" id="accounts"
                                       placeholder="登录账号"/>
                                <span class="icon icon-user margin-small"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="field field-icon-right">
                                <input type="password" class="input input-big" name="password" id="password"
                                       placeholder="登录密码"/>
                                <span class="icon icon-key margin-small"></span>
                            </div>
                        </div>
                    </div>
                    <div style="padding:30px;">
                        <input type="button" id="button" onclick="signIn()"
                               class="button button-block bg-main text-big input-big" value="登录">
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

</body>

<script src="static/lib/jquery/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="static/js/sweetalert-dev.js"></script>
<script language="JavaScript">function keyLogin() {
    if (event.keyCode == 13) //回车键的键值为13
        signIn(); //调用登录按钮的登录事件
}
</script>

<script>
    var website = 'http://news.whilte.com';
    function signIn() {
        //账号
        var accounts = $("#accounts").val();

        //密码
        var password = $("#password").val();
        if (accounts == null || accounts == '') {
            swal({
                title: "账号不能为空",
                type: "warning"
            });
        } else if (password == null || password == '') {
            swal({
                title: "密码不能为空",
                type: "warning"
            });
        } else {
            $.ajax({
                url: website + "/UserController/backstageLogin",
                type: "post",
                data: {
                    accounts: accounts,
                    password: password
                },
                success: function (data) {

                    if (data.code == 200) {
                        swal({
                            title: data.msg,
                            type: "success"
                        }, function () {
                            localStorage.setItem('accountsadmin',accounts);
                            localStorage.setItem('passwordadmin',password);
                            setTimeout(function () {
                                window.location.href = "static/html/index.html";
                            },500)
                        });
                    } else {
                        swal({
                            title: data.msg,
                            type: "error"
                        });
                    }
                }
            })
            /*swal({
                title: '登录成功',
                type: "success"
            }, function(isConfirm) {
                window.location.href = "static/html/index.html";
            });*/
        }
    }
</script>

</html>